let init={
    //管理员登录
    login:function (){
        $("#login").click(function (){
            layui.use(['layer','jquery'], function(){
                let layer = layui.layer;
                let $=layui.jquery;
                let zh=$("#yhm").val();
                let pwd=$("#mm").val();
                let flag=true;
                let phone=`/^1[3456789]d{9}$/`;
                if(zh=="" | pwd==""){
                    layer.msg('登陆信息不能为空!',{
                        icon:5,time:800
                    });
                    flag=false;
                }
                if(flag){
                    // $.ajax({
                    //     url:"",
                    //     data:{},
                    //     header:{"token":localStorage.getItem("token")},
                    //     success:function (data){
                    //
                    //     }
                    // })

                    $.post("http://localhost:8080/user/login",{"aPhone":zh,"aPwd":pwd},function (map){
                        if(map.data!=null){
                            if(map.data.astate==1){
                                layer.msg('该账号已经被封停!',{
                                    icon:4,time:800
                                });
                            }else{
                                layer.msg('正在登录中,请稍等...',{
                                    icon:16,time:1000
                                },function (){
                                    console.log(map.token);
                                    sessionStorage.setItem("aid",map.data.aid);
                                    sessionStorage.setItem("aname",map.data.aname);
                                    sessionStorage.setItem("atype",map.data.atype);
                                    localStorage.setItem("token",map.token);
                                    location.href="index.html";
                                });
                            }

                        }else{
                            layer.msg('登陆信息输入有误!',{
                                icon:5,time:800
                            });
                        }
                    })
                }
            });

        })
    }
}
$(init.login);